﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CodeCamp.Models.Schedule
{
    public class ScheduleGridModel
    {
        public ScheduleGridModel()
        {
            ErrorMsgs = new StringBuilder();
            Rooms = new Dictionary<int, Room>();
            //Sessions = new Dictionary<int, Timeslot.Session>();
            Timeslots = new Dictionary<int, Timeslot>();
        }

        /// <summary>
        /// Key is Room Id
        /// </summary>
        public Dictionary<int, Room> Rooms { get; private set; }

        /// <summary>
        /// Key is SessionId
        /// </summary>
        //public Dictionary<int, Timeslot.Session> Sessions { get; private set; }

        /// <summary>
        /// Key is TimeslotId
        /// </summary>
        public Dictionary<int, Timeslot> Timeslots { get; private set; }

        public int BuildingCount { get; set; }

        public int FloorCount { get; set; }

        public int CapacityCount { get; set; }

        public StringBuilder ErrorMsgs { get; private set; }

        public string EventShortName { get; set; }

        public class Room
        {
            public int RoomId { get; set; }
            public string Building { get; set; }
            public int Capacity { get; set; }
            public Nullable<int> Floor { get; set; }
            public string RoomName { get; set; }
            public bool ShowToPublic { get; set; }
        }

        public class Timeslot
        {
            public Timeslot()
            {
                GridCells = new Dictionary<int, GridCell>();
            }

            public int TimeslotId { get; set; }
            public string Name { get; set; }
            public DateTime StartTime { get; set; }
            public DateTime EndTime { get; set; }
            public int SessionCount { get; set; }
            /// <summary>
            /// Key is RoomId
            /// </summary>
            public Dictionary<int, GridCell> GridCells { get; private set; }

            public class GridCell
            {
                public GridCell()
                {
                    Sessions = new List<Session>();
                }
                public Room CellRoom { get; set; }
                public int RoomId { get; set; }
                public List<Session> Sessions { get; private set; }
            }
            public class Session
            {
                public int SessionId { get; set; }
                public string Title { get; set; }
                public int TimeslotId { get; set; }
                /// <summary>
                /// Used when editing in grid to remove session from schedule
                /// </summary>
                public bool Remove { get; set; }
                public int RoomId { get; set; }
            }
        }
    }
}